package com.example.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.Devices;
import com.example.entity.Log;
import com.example.entity.Params;
import com.example.exception.CustomException;
import com.example.repository.LogMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LogService extends ServiceImpl<LogMapper, Log> {

    @Resource
    private LogMapper logMapper;


    public PageInfo<Log> findBySearchOfLog(Params params){
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        List<Log> search = logMapper.findBySearchOfLog(params);
        return PageInfo.of(search);
    }

    @Transactional
    public void addLog(Log log){
        logMapper.insert(log);
    }

    public void deleteLog(Long id) {
        logMapper.deleteById(id);
    }


}
